package test;

public class MyRunnable implements Runnable {
    private int number;
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            //每次修改加锁
            synchronized (this) {
                System.out.println(Thread.currentThread().getName() +"number ========== " + (++number));
            }
        }

    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }
}
